How to tell if a view exists

Let's say I have a string s.  How can I tell whether a module has a view by the name of s defined?

Thanks,

Grasswistle


grasswistle - Fri Nov 29 12:05:25 EST 2013

Re: How to tell if a view exists
adevicq - Fri Nov 29 12:30:42 EST 2013

Hi,

You must try to load it. It is the only way I know...

Regards,

Alain

 

Re: How to tell if a view exists
grasswistle - Fri Nov 29 12:35:07 EST 2013

adevicq - Fri Nov 29 12:30:42 EST 2013

Hi,

You must try to load it. It is the only way I know...

Regards,

Alain

 

The problem is that if I try something like this,

load view "Sfsdaasdf"

there is no sign that the view doesn't exist.    Oh and "Sfsdaasdf", does not exist as a view... :)

Thanks,

Grasswistle

Re: How to tell if a view exists
adevicq - Fri Nov 29 12:39:08 EST 2013

grasswistle - Fri Nov 29 12:35:07 EST 2013

The problem is that if I try something like this,

load view "Sfsdaasdf"

there is no sign that the view doesn't exist.    Oh and "Sfsdaasdf", does not exist as a view... :)

Thanks,

Grasswistle

It returns a bool.

If false, the view can't be loaded...

Re: How to tell if a view exists
Mathias Mamsch - Sun Dec 01 12:53:16 EST 2013

adevicq - Fri Nov 29 12:30:42 EST 2013

Hi,

You must try to load it. It is the only way I know...

Regards,

Alain

 

And of course you can just iterate over the views inside a module and check if your view is there (without needing to load it):

string sViewName; for sViewName in views modCurrent do { ... }

(if I remember correctly, it might be that you need to pass a ModName_ or Item, check the DXL Manual).

Regards, Mathias

Re: How to tell if a view exists
dylandrush - Fri Dec 04 15:30:47 EST 2015

This is an old thread, but eh.

 

You could do something like the following:

 

ModName_ modName = module(fullName(current Module))

if (canRead(modName, view("Stsdaasdf"))) {
    print("This view does exist.\n")
}
else {
    print("This view doesn't exist...\n")   
}